<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="UTF-8">
<link rel="stylesheet" href="statics/css/jqueryMobile.css">
<link rel="stylesheet" href="statics/css/mobiscroll.css">
<script src="statics/js/jquery-1.12.4.js"></script>
<script src="statics/js/jquery.form.js"></script>
<script src="statics/js/jqueryMobile.js"></script>
<script src="statics/js/mobiscroll.js"></script>	
<script src="statics/js/area.js"></script>
<link rel="stylesheet" type="text/css" href="statics/css/test.css">

<script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.4.0.js"></script>

<script type="text/javascript">

$(function(){
		$.ajax({
			url:"rest/share",
			type:"post",
			data:{
				"url":window.location.href// 获取页面当前链接
			},
			dataType:"json",
			success: function(data){
			
			     alert(data.timestamp);
			     
				 wx.config({
				    debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
				    appId:data.appid, // 必填，公众号的唯一标识
				    timestamp: data.timestamp, // 必填，生成签名的时间戳
				    nonceStr: data.nonceStr, // 必填，生成签名的随机串
				    signature: data.signature,// 必填，签名
				    jsApiList: ["updateTimelineShareData"  ,"updateAppMessageShareData","onMenuShareAppMessage","onMenuShareTimeline"] // 必填，需要使用的JS接口列表
				});
				
				wx.ready(function () {
					//分享到朋友
					wx.updateAppMessageShareData({
			    	    title: '来自安然失笑i的分享', // 分享标题
			    	    desc: '测试分享功能', // 分享描述
			    	    link: window.location.href+"?id=111", // 分享链接
			    	    imgUrl: 'http://lead.taiwuyou.cn/chint-dl/mobile/cus_service.jpg', // 分享图标
			    	    type: 'link', // 分享类型,music、video或link，不填默认为link
			    	    success: function () { 
			    	        alert("分享成功");
			    	    },
			    	    cancel: function () { 
			    	        alert("未分享!");
			    	    }
					});
					//分享到QQ
		
			    });
			}
			
			
 
		});
 
	
		
	});




</script>		
</head>
<body>
	
	<button  type="button"  name="btn"  onclick="test()">点击分享b</button>
	
	
</body>

</html>
